<?php
/*
 * EmailComponent for CakePHP
 *
 * @author      gwoo <gwoo@rd11.com>
 * @version     0.10.8.2176
 * @license		OPPL
 *
 */
class PropComponent extends Object
{

	var $config = null;

	var $filename = 'application.properties';

	function __construct(){
		$this->config = $this->readConfigFile(CONFIGS . $this->filename);
	}
	
	function getValue($key)
	{
		if(!empty($key))
		{
			return ($this->config[low($key)]);
		}
		return false;
	}

	function readConfigFile($fileName) {
		$fileLineArray = file($fileName);

		foreach($fileLineArray as $fileLine) {
			$dataLine = trim($fileLine);
			$firstChar = substr($dataLine, 0, 1);

			if ($firstChar != '#' && $dataLine != '') {
				if ($firstChar == '[' && substr($dataLine, -1, 1) == ']') {
					// [section block] we might use this later do not know for sure
					// this could be used to add a key with the section block name
					// but it adds another array level
				} else {
					$delimiter = strpos($dataLine, '=');

					if ($delimiter > 0) {
						$key = strtolower(trim(substr($dataLine, 0, $delimiter)));
						$value = trim(substr($dataLine, $delimiter + 1));

						if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
							$value = substr($value, 1, -1);
						}

						$iniSetting[$key] = stripcslashes($value);
					} else {
						$iniSetting[strtolower(trim($dataLine))] = '';
					}
				}
			} else {
			}
		}

		return $iniSetting;
	}

}

?>